package com.ht.temp.service.impl;

import com.ht.temp.entity.Equipment;
import com.ht.temp.mapper.EquipmentMapper;
import com.ht.temp.service.IEquipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mayke_zhou
 * @since 2018-12-24
 */
@Service
@Transactional
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements IEquipmentService {
   @Autowired
    private EquipmentMapper equipmentMapper;


    @Override
    public int deleteByPrimaryKey(Integer equipmentId) {
        return equipmentMapper.deleteByPrimaryKey(equipmentId);
    }

    @Override
    public int insertSelective(Equipment record) {
        System.out.println(record.getEquipmentWorkshop());
        return equipmentMapper.insertSelective(record);
    }

    @Override
    public List<Equipment> selectByEquipment(Equipment record) {
        return equipmentMapper.selectByEquipment(record);
    }

    @Override
    public Equipment selectByPrimaryKey(Integer equipmentId) {
        return null;
    }

    @Override
    public Integer editByEquipment(Equipment record) {

        return equipmentMapper.updateByEquipment(record);
    }

    @Override
    public Integer editState(Integer state, Integer id) {
        System.out.println("before_state:"+state+","+"id:"+id);
        if(state == 0){
            state =1;
        }else if(state == 1){
            state =0;
        }
        System.out.println("after-state:"+state+","+"id:"+id);
        return equipmentMapper.updateEquipmentState(state,id);
    }
}
